package org.web.demo.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author yexi
 */
@WebServlet("/product")
public class ProductServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws
            ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        // 判断 Session 中是否有登录的标示，有则说明登录成功了，没有则说明没有登录
        Object user = req.getSession().getAttribute("USER_IN_SESSION");
        if (user == null) {
        // 没有登录滚去登录
            resp.sendRedirect("/login.jsp");
            return;
        }
        String cmd = req.getParameter("cmd");
        // 针对参数 cmd 值不同，分发到不同的方法去处理
/*        if ("delete".equals(cmd)) {
            delete(req, resp);
        } else if ("input".equals(cmd)) {
            input(req, resp);
        } else if ("saveOrUpdate".equals(cmd)) {
            saveOrUpdate(req, resp);
        } else {
            list(req, resp);
        }*/
    }
}
